<?php /* Smarty version Smarty 3.1.4, created on 2012-06-12 10:13:20
         compiled from "D:/Programme/Xampp/htdocs/BuildBase/templates\codeToGui.tpl" */ ?>
<?php /*%%SmartyHeaderCode:11504fd6f5bb366731-12191038%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'f1f9c86c899d91e1758bb2df908bd1b397f01f18' => 
    array (
      0 => 'D:/Programme/Xampp/htdocs/BuildBase/templates\\codeToGui.tpl',
      1 => 1339488444,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '11504fd6f5bb366731-12191038',
  'function' => 
  array (
  ),
  'version' => 'Smarty 3.1.4',
  'unifunc' => 'content_4fd6f5bb83959',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_4fd6f5bb83959')) {function content_4fd6f5bb83959($_smarty_tpl) {?><html>
    <head>
        <title>
            ist gut
        </title>
<!--        <script type="text/javascript" src="jquery-1.6.4.min.js"></script>-->
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link type="text/css" href="/Game/templates/js/custom/jquery-ui-1.8.20.custom.css" rel="Stylesheet" />
        <script src="/Game/templates/js/jquery-1.7.2.js"></script>
        <script src="/Game/templates/js/jquery-ui-1.8.20.custom.js"></script>
<!--	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.7.2.js"></script>-->
        <script src="/Game/templates/js/ui/jquery.ui.core.js"></script>
	<script src="/Game/templates/js/ui/jquery.ui.widget.js"></script>
	<script src="/Game/templates/js/ui/jquery.ui.mouse.js"></script>
	<script src="/Game/templates/js/ui/jquery.ui.resizable.js"></script>
<!--	<link rel="stylesheet" href="../demos.css">-->
	<style>
        body {
            overflow: auto;
        }
	#resizable { width: 90%; max-height: 90%; padding: 0.5em; }
	#resizable h3 { text-align: center; margin: 0; }

        .contents {
            position:relative;
            left:10px;
        }
        .lineNumber {
            border:1px solid black;
        }
        .left {
            float:left;
            text-align:left;
        }
	</style>
</head>
    </head>
    <body>
        push the button DOESN'T work, instead press a key like r in example,
        it greps out the GetFiles.php and debug it.
        <br>
        I worked with an attribute name "myattr" in the different divs
        <br>
        <input id="getDebug" class="left" type="button" value="get debug" />
        <div id="variables" class="left">
            this is input
        </div>
        <br>
        <br>
        <div id="last">
            last<input type="checkbox" name="all"/>
        </div>
        <br>
        <br>
        <div id="debugContent">
        </div>
        <script>
            jQuery(document).ready(function () {
                function contains(a, obj) {
                    var i = a.length;
                    while (i--) {
                       if (a[i] === obj) {
                           return true;
                       }
                    }
                    return false;
                }

//                jQuery('body').undelegate('#getDebug', 'click');
//                jQuery('body').delegate('#getDebug', 'click', function() {
                jQuery(document).keyup(function() {
                    // get lines that are open now
                    var last = false;
                    if (true == jQuery('#last input').is(':checked')) {
                        last = true;
                    }
//                    var childs = jQuery('#debugContent').children('div');
                    var jsonObject = {};
                    jsonObject['lineNumberOpen'] = [];
//                    if (childs.length) {
//                        childs.each(function() {
//                            if ('none' != jQuery(this).children('div').css('display')) {
//                                var divIdLineNumber = jQuery(this).attr('id');
//                                var cuttedDivIdLineNumber = divIdLineNumber.substring(8);
//                                var lineNumberEntry = {};
//                                lineNumberEntry['lineNumber'] = cuttedDivIdLineNumber;
//                                jsonObject['lineNumberOpen'].push(lineNumberEntry);
//                            }
//                        })
//                    }
                    var jsonLinesOpen = JSON.stringify(jsonObject);
                    // get variables that should stay open
                    var variables = jQuery('#variables input[type=checkbox]');
                    var variablesObject = {};
                    variablesObject['variablesOpen'] = [];
                    if (variables.length) {
                        variables.each(function() {
//                            console.log(jQuery(this));
                            if (true == jQuery(this).is(':checked')) {
                                variablesObject['variablesOpen'].push(jQuery(this).attr('name'));
                            }
                        })
                    }
//                    variablesObject['variablesOpen'] = variablesChecked;
                    var jsonVariablesOpen = JSON.stringify(variablesObject);
                    console.log(jsonVariablesOpen);
//
//                    console.log(jsonLinesOpen);

                    jQuery.ajax({
                        type: "POST",
                        url: "includes/CodeToGuiExe.php",
                        data: "text=getDebug&jsonLinesOpen=" + jsonLinesOpen + "&jsonVariablesOpen=" + jsonVariablesOpen,
                        datatype: 'json',
                        success: function(msg){
                            // create div content for vars
                            var jsonObject = JSON.parse(msg);
                            var divContent = '';
                            var lineNumberDivsStayOpen = [];
                            var allVariables = [];
                            var variablesOpen = []
                            for (key in jsonObject) {
                                if ('allVariables' != key && 'variablesOpen' != key) { // it is an exception, dirty coding
                                    var lineIdentifier = jsonObject[key];
                                    var codeLineNumber = parseInt(key);
                                    var divControlLineNumber = '<div id="control_' + codeLineNumber + '" class="lineNumber">' + codeLineNumber + '<br>';
                                    divContent += divControlLineNumber;
                                    if (undefined != lineIdentifier['open']) {
                                        lineNumberDivsStayOpen.push(key);
                                    }
                                    var counter = 0;
                                    var len = lineIdentifier.length;
                                    console.log(lineIdentifier);
                                    if (undefined != len) {
                                        for(varPlusContent in lineIdentifier) {
                                            console.log("len = " + len);

                                            var variable = lineIdentifier[varPlusContent]['var'];
                                            var content = lineIdentifier[varPlusContent]['content'];

                                            var divControlLineNumberIndex = '<div id="control_' + codeLineNumber + '_' + counter + '" class="contents" myattr="' + variable + '">' + '[' + counter + '] => ' + variable
                                            var divLineNumberContent = '<div class="contents_' + variable + '">' + content + '</div>';
                                            var divEnd = '</div>';
                                            if (last && len-1 == varPlusContent) {

                                                divContent += divControlLineNumberIndex + '<br>';
                                                divContent += divLineNumberContent;
                                                divContent += divEnd;
                                            } else if(!last) {
                                                if ('open' != varPlusContent) {
    //                                                var variable = lineIdentifier[varPlusContent]['var'];
    //                                                var content = lineIdentifier[varPlusContent]['content'];
    //
    //                                                var divControlLineNumberIndex = '<div id="control_' + codeLineNumber + '_' + counter + '" class="contents" myattr="' + variable + '">' + '[' + counter + '] => ' + variable
    //                                                var divLineNumberContent = '<div class="contents_' + variable + '">' + content + '</div>';
    //                                                var divEnd = '</div>';
                                                    divContent += divControlLineNumberIndex + '<br>';
                                                    divContent += divLineNumberContent;
                                                    divContent += divEnd;
                                                }
                                            }
                                            counter++;
                                        }
                                        divContent+= '</div>';
                                    }
                                    
                                } else { // the exception, dirty coding
                                    // create all variable checkboxes
                                    variablesOpen = jsonObject['variablesOpen'];
                                    allVariables = jsonObject['allVariables'];
                                    var variablesInput = '';
                                    for(i in allVariables) {
                                        var identifier = allVariables[i];
                                        if (true == contains(variablesOpen, identifier)) {
                                            variablesInput += identifier + '<input type="checkbox" name="' + identifier + '" checked="checked"/>, ';
                                        } else {
                                            variablesInput += identifier + '<input type="checkbox" name="' + identifier + '"/>, ';
                                        }
                                    }
                                    jQuery('#variables').html(variablesInput);
                                }
                                
                            }
                            // hide the variables
                            var debugContent = jQuery('#debugContent');
                            debugContent.html(divContent);
                            debugContent.find('.contents').hide();
                            debugContent.find('.lineNumber').click(function() {
                                jQuery(this).find('.contents').toggle();
                            })
                            // display checked variables
                            var relativeDivWithMyAttribute = debugContent.find('div[myattr]');
                            relativeDivWithMyAttribute.each(function() {
                                var strToFind = jQuery(this).attr('myattr');
                                if (contains(variablesOpen, strToFind)) {
                                    jQuery(this).css('display', 'block');
                                }
                            });
//                            for(key in lineNumberDivsStayOpen) {
//                                debugContent.find('#control_' + lineNumberDivsStayOpen[key]).find('div').css('display', 'block');
//                            }
                        },
                        error: function() {
                            alert('error occurred between ajax');
                        }
                    });
                });
            });
	</script>
    </body>
</html><?php }} ?>